package com.gongsir.controller;

import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

/**
 * @author 码之泪殇
 * @date 2020/8/20 09:40
 * 到达胜利之前，无法回头
 * 系统view页面管理
 */
@Controller
@RequestMapping("/page")
@Slf4j
public class PageController {

    /**
     * 自动页面跳转, 解析url中的dir和pageName, 跳转到相应的views/dir/pageName.jsp
     */
    @GetMapping(path = "/{dir}/{pageName}")
    public String getPage(@PathVariable("dir") String dir, @PathVariable("pageName")String pageName){
        String url = "root";
        if (url.equals(dir)) {
            url = pageName;
        } else {
            url = dir + "/" + pageName;
        }
        log.info("打开页面路径:{}", url);
        return url;
    }
}
